package com.mysoft.gfyx.workbench.controller;

import com.mysoft.framework.rpc.annotation.PubAction;
import com.mysoft.framework.rpc.annotation.PubService;
import com.mysoft.framework.rpc.contants.RequestPrefix;
import com.mysoft.gfyx.workbench.controller.dto.MySubscriptionPageResponseDto;
import com.mysoft.gfyx.workbench.controller.dto.MySubscriptionResponseDto;
import com.mysoft.gfyx.workbench.controller.dto.PageDto;
import com.mysoft.gfyx.workbench.remoteservice.RemoteMySubscriptionService;
import com.mysoft.gfyx.workbench.remoteservice.RemoteSearchOpportunitiesService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import java.util.List;

@PubService(value = "/mySubscriptionDataApi", prefix = RequestPrefix.API)
@Tag(name = "指标控制器-API")
public class MySubscriptionDataApiController {

    @Resource
    private RemoteMySubscriptionService remoteMySubscriptionService;

    @Resource
    private RemoteSearchOpportunitiesService remoteSearchOpportunitiesService;

    @PubAction(value = "/list", method = RequestMethod.POST)
    public List<MySubscriptionResponseDto> myList() {
        boolean isEnable = remoteMySubscriptionService.isSetSubscriptionConfig();
        PageDto pageDto = new PageDto();
        pageDto.setPage(1);
        pageDto.setPageSize(30);
        MySubscriptionPageResponseDto result;
        result = remoteSearchOpportunitiesService.getLatestOpportunities(pageDto);
        return result.getData();
    }
}
